<template>
  <div class="wrap w-my" id="app">
    <header>
        
    </header>
    <div class="head">
        <div class="box clearfix">
           <router-link :to="userInfo? '':'/register/login'">
            <div class="img">
              <img src="@/assets/img/headImg.png" alt="" v-if='userInfo' />
              <img src="@/assets/img/headImg.png" alt="" v-else />
            </div>
            <div class="info" v-if='userInfo'>
                <h4>{{userInfo.user_nickname}}</h4>
                <p>{{biding_num_text}} {{biding_num}}&nbsp;&nbsp;&nbsp;&nbsp;{{enlist_num_text}} {{enlist_num}}</p>
            </div>
            <div class="info" v-else>
                <h4>登录/注册</h4>
                <p>招标中 0&nbsp;&nbsp;&nbsp;&nbsp;已投 0</p>
            </div>

<!--                 <img class="icon" src="@/assets/img/r_b.png" alt="" />
 -->           </router-link >

        </div>

    </div>
    <section class="order">
        <p class="tit">我的订单</p>
        <div class="items clearfix">
            <div class="item" @click="toDidlist(0)">
                    <img src="@/assets/img/my_menus1.png" alt="" />
                    <p>招标中</p>
            </div>
            <div class="item" @click="toDidlist(1)">
                    <img src="@/assets/img/my_menus2.png" alt="" />
                    <p>已中标</p>
            </div>
            <div class="item" @click="toDidlist(2)">
                    <img src="@/assets/img/my_menus3.png" alt="" />
                    <p>未中标</p>
            </div>
            <div class="item" @click="toDidlist(3)">
                    <img src="@/assets/img/my_menus4.png" alt="" />
                    <p>报价人数不足</p>
            </div>
            <div class="item" @click="toDidlist(4)">
                    <img src="@/assets/img/my_menus5.png" alt="" />
                    <p>效益作废</p>
            </div>
            <div class="item" @click="toDidlist(5)">
                    <img src="@/assets/img/my_menus6.png" alt="" />
                    <p>拒收</p>
            </div>
            <div class="item" @click="toDidlist(6)">
                    <img src="@/assets/img/my_menus7.png" alt="" />
                    <p>等待确认结果</p>
            </div>
            <div class="item" @click="toDidlist(7)">
                    <img src="@/assets/img/my_menus8.png" alt="" />
                    <p>成交</p>
            </div>
        </div>
    </section>
    <ul class="lists">
        <li @click="toAuth">
                认证
                <img class="icon" src="@/assets/img/r_b.png" alt="" />
        </li>
        <li @click="toEditpass">
                修改密码
                <img class="icon" src="@/assets/img/r_b.png" alt="" />
        </li>
       <!--  <li @click="toAbout">
                关于我们
                <img class="icon" src="@/assets/img/r_b.png" alt="" />
        </li> -->
        <li class="friend" @click="toInviteman">
                成为合伙人
                <img class="icon" src="@/assets/img/r_b.png" alt="" />
        </li>
        <li class="friend" @click="toRule">
                规则中心
                <img class="icon" src="@/assets/img/r_b.png" alt="" />
        </li>
         <li class="friend" @click="toAbout">
                关于我们
                <img class="icon" src="@/assets/img/r_b.png" alt="" />
        </li>
        <li class="friend" @click="outLogin">
                退出登录
        </li>
    </ul>
    <Bartab />

</div>

</template>

<script>
// @ is an alias to /src
import Bartab from '@/components/Bartab.vue'

export default {
  name: 'my',
  inject:['reload'],
  data(){
    return{
        userInfo:null,
        headImg:null,

        biding_num_text:'招标中',
        enlist_num_text:'已投',
        biding_num:0,
        enlist_num:0
          
     }
  },
  async created(){
       this.userInfo = this.getUserInfo()
       let re = await this.$axios.get('user/myInit')
       if(re.code == 200){
              this.biding_num = re.data.biding_num
              this.enlist_num = re.data.enlist_num
              this.biding_num_text = re.data.biding_num_text
              this.enlist_num_text = re.data.enlist_num_text

          }
  },

  mounted(){
     
            
  },
  components: {
    'Bartab':Bartab
  },
  methods:{
    //去标书列表
    toDidlist(id){
        this.$router.push({path:'/my/bidlist',query: {
            id:id
        }})
        
    },
    //去认证
    async toAuth(){
       let user = await this.$axios.get('user/getUserByToken')
        if(user.code == 200){
              if(user.data.user_type ==0){
                this.$router.push({path:'/register/status'})
                 
              }else{
                 this.$router.push({path:'/my/usertype'})
               
              }
          
           }
    },
    
    //修改密码
    async toEditpass(){
       let user = await this.$axios.get('user/getUserByToken')
        if(user.code == 200){
              if(user.data.user_type ==0){
                this.$router.push({path:'/register/status'})
                 
              }else{
                 this.$router.push({path:'/my/editpass'})
               
              }
          
           }

    },
    //成为合伙人
    async toInviteman(){
    let user = await this.$axios.get('user/getUserByToken')
        if(user.code == 200){
             if(user.data.is_invite ==0){

                this.$createDialog({
                    type: 'confirm',
                    icon: '',
                    title: '提示',
                    content: '成为合伙人,生成邀请码,可推荐同行入驻,赢取返利!',
                    onConfirm: () => {
                       let re =  this.$axios.post('user/goInvite')
                       .then(response => {
                           if(response.code == 200){
                              this.$router.push({path:'/my/inviteman'})
                            }
                       })
                           
                     },
                  }).show()

              }else{
                 this.$router.push({path:'/my/inviteman'})
               
              }
          
         }
              
    },
    gologin(){
        this.$router.push({path:'/register/login'})
    },
    outLogin(){
        this.$createDialog({
        type: 'confirm',
        icon: '',
        title: '提示',
        content: '退出登录，无法看到订单信息，确定退出？',
        onConfirm: () => {
          localStorage.setItem('userInfo','')
            this.reload()        
        },
      }).show()
        

    },
    toRule(){
       this.$router.push({path:'/file/filelist'})

    },
    //去关于我们
    toAbout(){
        this.$router.push({path:'/file/about'})
 
    },

  }
}
</script>

